package com.softeem.net;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/4/8 16:00
 * @description
 */
public class Client {
    public static void main(String[] args) {
        //连接服务器
        try {
            Socket sk = new Socket("192.168.6.100", 9000);
            OutputStream os = sk.getOutputStream();
            PrintWriter pw = new PrintWriter(os);
            //控制台输入的数据
            Scanner input = new Scanner(System.in);
            String msg = null;
            while (true){
                msg = input.nextLine();
                //发送给服务器
                pw.println(msg);
                pw.flush();
                if (msg!=null&&msg.equals("q")){
                    System.exit(0);
                    break;
                }
            }
            pw.close();
            os.close();
            sk.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
